package cn.tedu.review;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author ：Dsi
 * @date ：2021/11/18 9:43
 * Describe ：该类用于回顾集合
 */
public class TestCollection {
    public static void main(String[] args) {
        Collection<Integer> c = new ArrayList();
        /*
        for (int i = 0; i < 500; i++) {
            c.add(i);
        }
        */
        c.add(100);
        c.add(200);
        c.add(300);
        c.add(400);
        c.add(500);
        System.out.println(c);
        //c.clear();
        System.out.println(c.hashCode());
        System.out.println(c.equals(100));
        System.out.println(c.isEmpty());
        System.out.println(c.size());
        System.out.println(Arrays.toString(c.toArray()));
        System.out.println(c.toArray().length);
        System.out.println();
        Collection c2=new ArrayList();
        c2.add(2);
        c2.add(4);
        c2.add(6);
        System.out.println(c2);
        c.addAll(c2);
        System.out.println(c);
        System.out.println(c.containsAll(c2));
        System.out.println(c);
        System.out.println(c.removeAll(c2));
        System.out.println(c);
        System.out.println(c.retainAll(c2));
        System.out.println(c);

        Iterator<Integer> i = c2.iterator();
        while (i.hasNext()){
            System.out.println(i.next());
        }


    }
}
